package com.fenghongzhang.day004;

import androidx.appcompat.app.AppCompatActivity;
import androidx.fragment.app.FragmentManager;
import androidx.fragment.app.FragmentTransaction;

import android.os.Bundle;
import android.view.View;

public class MainActivity extends AppCompatActivity {
    BlankFragment blankFragment;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        blankFragment = new BlankFragment();

    }

    //添加
    public void btn(View view) {
        //管理者
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        //开始事务
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
        fragmentTransaction.add(R.id.ll,blankFragment);
//        fragmentTransaction.add
//        fragmentTransaction.replace(R.id.ll,new BlankFragment2());
//        fragmentTransaction.remove(blankFragment);
//        fragmentTransaction.hide(blankFragment);
//        fragmentTransaction.show(blankFragment);
//        fragmentTransaction.replace()
        //提交事务
        fragmentTransaction.commit();
    }


    //删除
    public void btn2(View view) {
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        //开始事务
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
//        fragmentTransaction.remove(blankFragment);
//        fragmentTransaction.show(blankFragment);
        //提交事务
        fragmentTransaction.commit();
    }

    public void btn4(View view) {
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        //开始事务
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
//        fragmentTransaction.remove(blankFragment);
//        fragmentTransaction.show(blankFragment);
        fragmentTransaction.show(blankFragment);
        //提交事务
        fragmentTransaction.commit();

    }

    public void btn3(View view) {
        FragmentManager supportFragmentManager = getSupportFragmentManager();
        //开始事务
        FragmentTransaction fragmentTransaction = supportFragmentManager.beginTransaction();
//        fragmentTransaction.remove(blankFragment);
//        fragmentTransaction.show(blankFragment);
        fragmentTransaction.hide(blankFragment);
        //提交事务
        fragmentTransaction.commit();
    }
}
